#!/bin/bash
source "${LMD_BASE_INSTALL_SCRIPT_DIR}/global/conda_run.sh"
ensure_numba_0_61_2() {
    local pkg="numba"
    local target="0.61.2"
    local bad_versions=("0.62.0" "0.62.0rc1" "0.62.0rc2")
    local current=""
    current=$(conda_run_cmd python -c "import $pkg; print($pkg.__version__)" 2>/dev/null)

    local install_needed=false

    echo "Ensuring $pkg==$target..."
    echo "current $current"

    # If not installed or in bad version list
    if [ -z "$current" ]; then
        echo "Not installed."
        install_needed=true
    else
        echo "Current version: $current"
        for v in "${bad_versions[@]}"; do
            [ "$current" = "$v" ] && install_needed=true && break
        done
    fi

    # Install or reinstall
    if [ "$install_needed" = true ]; then
        echo "Installing $pkg==$target..."
        conda_run_pip_install "$pkg==$target"
    else
        echo "Version OK, no action needed."
    fi
}